<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--end form -->
<title>Thêm loại sách</title>
<script type="text/javascript">
	$(function() {
		$('input').checkBox();
		$('#toggle-all').click(function() {
			$('#toggle-all').toggleClass('toggle-checked');
			$('#mainform input[type=checkbox]').checkBox('toggle');
			return false;
		});
	});
</script>

<!--  styled select box script version 2 -->

<script type="text/javascript">
	$(document).ready(function() {
		$('.styledselect_form_1').selectbox({
			inputClass : "styledselect_form_1"
		});
		$('.styledselect_form_2').selectbox({
			inputClass : "styledselect_form_2"
		});
	});
</script>

<!--  styled file upload script -->

<script type="text/javascript" charset="utf-8">
	$(function() {
		$("input.file_1")
				.filestyle(
						{
							image : "<spring:theme code='theme.admin'/>/imageForms/upload_file.gif",
							imageheight : 29,
							imagewidth : 78,
							width : 300
						});
	});
</script>
</head>
<body>
	<div id="page-heading">
		<h1>
			${titlePage}
		</h1>
	</div>

	<!-- start id-form -->
	<form:form action="save-booktype" commandName="bookTypeVO" method="POST" id="addBookType">
		<form:hidden path="id"/>
		<table border="0" cellpadding="0" cellspacing="0" id="id-form">
			<tr>
				<th valign="top">Name</th>
				<td><form:input path="name" class="inp-form"/></td>
				<td><form:errors path="name" cssClass="error"></form:errors>
					<c:if test="${nameExited}">
						<span class="error">Tên không hợp lệ hoặc đã tồn tại!</span>
					</c:if>
				</td>
			</tr>
			
			<tr>
				<th valign="top">Trạng thái:</th>
				<td>
					<form:radiobutton path="active" value="1" class=".inp-form-radio" /><label>Hiển thị</label> 
					<form:radiobutton path="active" value="0" class=".inp-form-radio" /><label>Không hiển thị</label>
				</td>
				<td><form:errors path="active" class="error" /></td>
			</tr>

			<tr>
				<th>&nbsp;</th>
				<td valign="top"><input type="submit"
					value="Lưu" class="form-submit" />
					<input type="reset" value="Hủy" class="form-reset" onclick="window.location.href='booktype-info'"/></td>
				<td></td>
			</tr>
		</table>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function(){
			initCkEditor();
			var isAddSuccessful = '${addStatus}';
			if(isAddSuccessful == 'true'){
				var message = "<p style='font-size: 12px;'>Lưu thành công! </p>";		
				jNotify(message,{
				     autoHide : true, 
				     TimeShown : 3000,
				     HorizontalPosition : 'center',
				     onCompleted : function(){
				    	 window.location.href = "booktype-info";   
					 }
				   }
				 );	
			}
		});
		
		function initCkEditor() {
			CKEDITOR.replace('editor');
		}
	</script>
</body>
</html>